﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ChatDAL;
using System.Data.Entity;

namespace ChatASP
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            List<ChatDAL.Channel> channels = ChatManagement.GetAllChannels();
            ChannelListView.DataSource = channels;
            ChannelListView.DataBind();
        }

        protected void JoinChannel(object sender, EventArgs e)
        {
            string id = (sender as LinkButton).ClientID.Substring((sender as LinkButton).ClientID.Length - 1);
            int channelID = int.Parse(id);
            Session["channel"] = channelID + 1;
            Response.Redirect("~/Channel.aspx");
        }
    }
}
